﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RanbuUT
{
    public class TestHelper
    {
        public static void AreEqual(Stream expected, Stream actual)
        {
            expected.Seek(0, SeekOrigin.Begin);
            actual.Seek(0, SeekOrigin.Begin);
            for (var e = expected.ReadByte(); e != -1; e = expected.ReadByte())
            {
                var a = actual.ReadByte();
                if (e != a)
                {
                    throw new AssertFailedException(
                        string.Format("Difference at offset {0:X8}. Expected: {1:X2}, Actual: {2:X2}",
                        expected.Position, e, a));
                }
            }

            Assert.AreEqual(-1, actual.ReadByte(), "Error: actual stream is longer than expected.");
        }
    }
}
